package com.caizi.socket.normal;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.Socket;

public class Client {

    public void talk() throws IOException {
        Socket socket = new Socket("localhost", 1111);
        OutputStream outputStream = socket.getOutputStream();
        PrintWriter pw = new PrintWriter(outputStream, true);
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String msg = null;
        while ((msg = br.readLine()) != null) {
            pw.println(msg);
            if ("bye".equals(msg)) {
                break;
            }
        }
    }

    public static void main(String[] args) throws IOException {
        new Client().talk();
    }
}
